using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Lesson23 : MonoBehaviour
{
   public float Speed = 10f;
    public float RotateSpeed = 20f;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
            this.transform.Translate(Vector3.forward * Time.deltaTime * Speed*Input.GetAxis("Vertical"));
        this.transform.Rotate(Vector3.up, Time.deltaTime * RotateSpeed * Input.GetAxis("Horizontal"));
    if(Input.GetKeyDown(KeyCode.J))
        {
            Collider[] c = Physics.OverlapBox(this.transform.position + this.transform.forward,
                Vector3.one * 0.5f,
                this.transform.rotation,
                1 << LayerMask.NameToLayer("Monster")
                );
           for(int i=0; i<c.Length; i++)
            {
                print(c[i].name);
            }
        }
        if (Input.GetKeyDown(KeyCode.K))
        {
            Collider[] c = Physics.OverlapCapsule(this.transform.position + this.transform.forward*0.25f,
                this.transform.position + this.transform.forward * 4.75f,
                           0.25f,
                      1 << LayerMask.NameToLayer("Monster")
                      
                           );
            for (int i = 0; i < c.Length; i++)
            {
                print(c[i].name);
            }
        }
    
    }
}
